<?php
	include_once 'isLogin.php';
	
	$table_name = "setting";
	
	if($_GET['action']=='test_email'){
		$site_name = $commonc->getInfo($table_name, "6");
		
		##########设置部分##########
		$server = $_POST['values']['0'];//SMTP服务器
		$port = $_POST['values']['1'];//SMTP服务器端口
		$from = $_POST['values']['2'];//SMTP服务器的用户邮箱
		$username = $_POST['values']['3'];//SMTP服务器的用户帐号
		$password = $_POST['values']['4'];//SMTP服务器的用户密码
		$name = $site_name['value'];
		##########设置部分##########
		
		##########动态部分##########
		$sendType = "to";
		$to = $_POST['values']['5'];//发送给谁
		$subject = "测试邮件";
		$body = "这是一封测试邮件";
		$debug = false;
		$file = '';
		$isSecurity = true;
		##########设置部分##########
		
		##########发送部分##########
		$email = new email($server, $username, $password, $port, $from, $name, $sendType, $to, $subject, $body, $debug, $file, $isSecurity);
		if($email){
			echo '1';
		}else{
			echo '0';
		}
		##########发送部分##########
		exit();
	}
	
	if($_GET['op']!=false){
		$op = $_GET['op'];
	}else{
		$op = 'info';
	}
	$smarty->assign("op",$op);
	$menu = array('info'=>'网站信息','email'=>'企业邮箱');
	$smarty->assign("title",$menu[$op]);
	
	$sql = $table_name." where class='".$op."' order by listorder asc,id asc";
	$config_base_arr = $commonc->getList($sql);
	$smarty->assign("config_base_arr",$config_base_arr['result']);
	
	if (isset($_POST) && !empty($_POST)){
		foreach($config_base_arr['result'] as $k=>$v){
			$arr = array("value"=>$_POST[$v['key']]);
			$commonc->update($table_name, $arr, "id='".$v['id']."'");
		}
		echo $commonc->submitAlert("保存成功", "set.php?op=".$op);
	}
	
	$smarty->display("set.html");
?>